package com.hooware.dao;

import com.hooware.domain.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IPermissionDao {

    @Select("select * from permission")
    List<Permission> findAll();

    @Insert("insert into permission values(default, #{permissionName}, #{url})")
    void savePermission(Permission permission);

    @Delete("delete from permission where id = #{id}")
    void deletePermission(String id);

    @Select("select * from permission where id in (select permissionid from role_permission where roleid = #{id}) ")
    List<Permission> findPermissionByRoleId(String id);

    @Select("select * from permission where id = #{id}")
    Permission findById(String id);
}
